winsafe\dxgi\com_interfaces/
idxgisurface.rs

1#![allow(non_camel_case_types, non_snake_case)]
2
3use crate::co;
4use crate::decl::*;
5use crate::dxgi::vts::*;
6use crate::kernel::privs::*;
7use crate::ole::privs::*;
8use crate::prelude::*;
9
10com_interface! { IDXGISurface: "cafcb56c-6ac3-4889-bf47-9e23bbd260ec";
11	/// [`IDXGISurface`](https://learn.microsoft.com/en-us/windows/win32/api/dxgi/nn-dxgi-idxgisurface)
12	/// COM interface.
13	///
14	/// Automatically calls
15	/// [`Release`](https://learn.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-release)
16	/// when the object goes out of scope.
17}
18
19impl dxgi_IDXGISurface for IDXGISurface {}
20impl dxgi_IDXGIDeviceSubObject for IDXGISurface {}
21impl dxgi_IDXGIObject for IDXGISurface {}
22
23/// This trait is enabled with the `dxgi` feature, and provides methods for
24/// [`IDXGISurface`](crate::IDXGISurface).
25///
26/// Prefer importing this trait through the prelude:
27///
28/// ```no_run
29/// use winsafe::prelude::*;
30/// ```
31pub trait dxgi_IDXGISurface: dxgi_IDXGIDeviceSubObject {
32	/// [`IDXGISurface::GetDesc`](https://learn.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgisurface-getdesc)
33	/// method.
34	#[must_use]
35	fn GetDesc(&self) -> HrResult<DXGI_SURFACE_DESC> {
36		let mut desc = DXGI_SURFACE_DESC::default();
37		ok_to_hrresult(unsafe {
38			(vt::<IDXGISurfaceVT>(self).GetDesc)(self.ptr(), pvoid(&mut desc))
39		})
40		.map(|_| desc)
41	}
42
43	/// [`IDXGISurface::Map`](https://learn.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgisurface-map)
44	/// method.
45	#[must_use]
46	fn Map(&self, map_flags: co::DXGI_MAP) -> HrResult<DXGI_MAPPED_RECT> {
47		let mut mr = DXGI_MAPPED_RECT::default();
48		ok_to_hrresult(unsafe {
49			(vt::<IDXGISurfaceVT>(self).Map)(self.ptr(), pvoid(&mut mr), map_flags.raw())
50		})
51		.map(|_| mr)
52	}
53
54	fn_com_noparm! { Unmap: IDXGISurfaceVT;
55		/// [`IDXGISurface::Unmap`](https://learn.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgisurface-unmap)
56		/// method.
57	}
58}